home *** CD-ROM | disk | FTP | other *** search
- /* WARNING: THIS EXAMPLE IS QUICK & DIRTY!!! Its only purpose is to */
- /* demonstrate how certain MB_lib functions are used and how they work. */
- /* While the code is a functional program, no attempt has been made to */
- /* clean up the code or to streamline it, and I've economized a bit on */
- /* error checking since I've made this in a hurry. However, if you're */
- /* able to use MB_lib, odds are that you also know how to write neat code. */
-
- /* Write a demo message to All in board 1. */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "mb_lib.h"
-
- MSGHDR_RECORD myhdr; /* Message header */
- M_TEXT mytext; /* Text handle */
- char buf [20]; /* String buffer */
-
- void main () {
- if (msg_open ("C:\\MSGBASE")) {
- puts ("Error opening message base");
- exit (1);
- }
- mytext = txt_new ("This is the first paragraph of this message. \n");
- txt_add (mytext, "Text will be added until a Hard Carriage Return");
- txt_add (mytext, "is encountered. I've added one to this line.\r");
- txt_add (mytext, "This is the second paragraph. As you can see the \\n, ");
- txt_add (mytext, "which was added above, has been ignored according ");
- txt_add (mytext, "to FSC-0001.\r");
- sprintf (buf, "%cPID: MB_LIB 1.0\r", KLUDGE); /* Add product ID */
- txt_add (mytext, buf);
- msg_hdr_clear (& myhdr); /* Now build the message header */
- myhdr.dest_net = 1331; /* To: 27:1331/703.0 */
- myhdr.dest_node = 703;
- myhdr.dest_zone = 27;
- myhdr.orig_net = 285; /* From: 2:285/504.0 */
- myhdr.orig_node = 504;
- myhdr.orig_zone = 2;
- myhdr.msg_attr = MA_PRIVATE | MA_LOCAL;
- myhdr.board = 1; /* Tell him where to put it :-) */
- strcpy (myhdr.who_from, "Frank Van.wensveen");
- strcpy (myhdr.who_to, "All");
- strcpy (myhdr.subject, "Testing, testing...");
- if (msg_lock ("C:\\RA\\SEMAFORE")) {
- puts ("Error locking message base");
- exit (1);
- }
- if (msg_write_new (& myhdr, mytext)) /* See how easy it is? */
- printf ("Error %d writing message base:\n%s", errortype, errorstring);
- msg_unlock ();
- msg_close ();
- }